package com.ruoyi.system.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.PageRecommend;
import com.ruoyi.system.service.IPageRecommendService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 页面推荐Controller
 * 
 * @author ruoyi
 * @date 2021-04-07
 */
@RestController
@RequestMapping("/system/pagerecommend")
public class PageRecommendController extends BaseController
{
    @Autowired
    private IPageRecommendService pageRecommendService;

    /**
     * 查询页面推荐列表
     */
    @PreAuthorize("@ss.hasPermi('system:pagerecommend:list')")
    @GetMapping("/list")
    public TableDataInfo list(PageRecommend pageRecommend)
    {
        List<PageRecommend> list = pageRecommendService.selectPageRecommendList(pageRecommend);
        return getDataTable(list);
    }

    /**
     * 导出页面推荐列表
     */
    @PreAuthorize("@ss.hasPermi('system:pagerecommend:export')")
    @Log(title = "页面推荐", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(PageRecommend pageRecommend)
    {
        List<PageRecommend> list = pageRecommendService.selectPageRecommendList(pageRecommend);
        ExcelUtil<PageRecommend> util = new ExcelUtil<PageRecommend>(PageRecommend.class);
        return util.exportExcel(list, "pagerecommend");
    }

    /**
     * 获取页面推荐详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:pagerecommend:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(pageRecommendService.selectPageRecommendById(id));
    }

    /**
     * 新增页面推荐
     */
    @PreAuthorize("@ss.hasPermi('system:pagerecommend:add')")
    @Log(title = "页面推荐", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PageRecommend pageRecommend)
    {
        return toAjax(pageRecommendService.insertPageRecommend(pageRecommend));
    }

    /**
     * 修改页面推荐
     */
    @PreAuthorize("@ss.hasPermi('system:pagerecommend:edit')")
    @Log(title = "页面推荐", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PageRecommend pageRecommend)
    {
        return toAjax(pageRecommendService.updatePageRecommend(pageRecommend));
    }

    /**
     * 删除页面推荐
     */
    @PreAuthorize("@ss.hasPermi('system:pagerecommend:remove')")
    @Log(title = "页面推荐", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(pageRecommendService.deletePageRecommendByIds(ids));
    }
}
